load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "tuners",
    srcs = [
        "aggregated_tunable.go",
        "aio.go",
        "check.go",
        "checked_tunable.go",
        "checker.go",
        "clocksource.go",
        "disk_checkers.go",
        "disk_nomerges_tuner.go",
        "disk_scheduler_tuner.go",
        "disk_tuner.go",
        "disks_irq_tuner.go",
        "equality_checker.go",
        "file_existance_checker.go",
        "float_checker.go",
        "fstrim.go",
        "gcp_disk_write_cache_tuner.go",
        "int_checker.go",
        "iotune.go",
        "kernel_version.go",
        "kernel_version_darwin.go",
        "kernel_version_linux.go",
        "net_checkers.go",
        "net_tuners.go",
        "redpanda_checkers.go",
        "swappiness.go",
        "thp.go",
        "tunable.go",
        "tune_result.go",
    ],
    importpath = "github.com/redpanda-data/redpanda/src/go/rpk/pkg/tuners",
    visibility = ["//visibility:public"],
    deps = [
        "//src/go/rpk/pkg/cloud/gcp",
        "//src/go/rpk/pkg/cloud/provider",
        "//src/go/rpk/pkg/config",
        "//src/go/rpk/pkg/os",
        "//src/go/rpk/pkg/redpanda",
        "//src/go/rpk/pkg/system",
        "//src/go/rpk/pkg/system/systemd",
        "//src/go/rpk/pkg/tuners/disk",
        "//src/go/rpk/pkg/tuners/executors",
        "//src/go/rpk/pkg/tuners/executors/commands",
        "//src/go/rpk/pkg/tuners/iotune",
        "//src/go/rpk/pkg/tuners/irq",
        "//src/go/rpk/pkg/utils",
        "@com_github_pkg_errors//:errors",
        "@com_github_spf13_afero//:afero",
        "@org_uber_go_zap//:zap",
    ] + select({
        "@rules_go//go/platform:aix": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:android": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:darwin": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:dragonfly": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:freebsd": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:illumos": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:ios": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:js": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:linux": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:netbsd": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:openbsd": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:plan9": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "@rules_go//go/platform:solaris": [
            "//src/go/rpk/pkg/cloud",
            "//src/go/rpk/pkg/net",
            "//src/go/rpk/pkg/system/filesystem",
            "//src/go/rpk/pkg/tuners/ethtool",
            "//src/go/rpk/pkg/tuners/hwloc",
            "//src/go/rpk/pkg/tuners/network",
            "@com_github_hashicorp_go_multierror//:go-multierror",
            "@com_github_lorenzosaino_go_sysctl//:go-sysctl",
        ],
        "//conditions:default": [],
    }),
)

go_test(
    name = "tuners_test",
    size = "small",
    srcs = [
        "aggregated_tunable_test.go",
        "aio_test.go",
        "checked_tunable_test.go",
        "disk_nomerges_tuner_test.go",
        "disk_scheduler_tuner_test.go",
        "disks_irq_tuner_test.go",
        "equality_checker_test.go",
        "float_checker_test.go",
        "fstrim_test.go",
        "gcp_disk_write_cache_tuner_test.go",
        "int_checker_test.go",
        "kernel_version_test.go",
        "net_tuners_test.go",
        "redpanda_checkers_test.go",
        "swappiness_test.go",
        "thp_test.go",
        "tune_result_test.go",
    ],
    embed = [":tuners"],
    deps = [
        "//src/go/rpk/pkg/cloud/provider",
        "//src/go/rpk/pkg/os",
        "//src/go/rpk/pkg/system/systemd",
        "//src/go/rpk/pkg/tuners/disk",
        "//src/go/rpk/pkg/tuners/ethtool",
        "//src/go/rpk/pkg/tuners/executors",
        "//src/go/rpk/pkg/tuners/hwloc",
        "//src/go/rpk/pkg/tuners/irq",
        "//src/go/rpk/pkg/tuners/network",
        "//src/go/rpk/pkg/utils",
        "@com_github_spf13_afero//:afero",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
    ],
)
